<?php
    require "../public/functions.php";

    $id = $_POST['id'];
    $status = $_POST['status'];
    $webname = $_POST['webname'];
    $logo = $_FILES['file'];
    $copy = $_POST['copy'];
    $keywords = $_POST['keywords'];

    $path="../../public/home/img/";
    $maxsize=0;
    $fileType=array("image/jpeg","image/gif","image/png");
    $res=upload($path,$fileType,$maxSize=0,$logo);
//             var_dump($res);

    $newName = $res['newName'];

    $line = "x_";
    $maxw =200;
    $maxh =200;
    getImages($path,$newName,$line,$maxw,$maxh);

//    $path = rtrim($path,'/').'/';
    $newlogo = $line.$newName;

    $link = mysqli_connect("localhost","root","") or die("数据连接失败");
    mysqli_set_charset($link,"utf8");
    mysqli_select_db($link,"bbs");
    $sql = "update config set webname='{$webname}',keywords='{$keywords}',logo='{$newlogo}',copy='{$copy}',status='{$status}' where id={$id}";
    mysqli_query($link,$sql);
    if(mysqli_affected_rows($link)>0){
        echo "<script>alert('修改成功！');window.location.href='./revise.php';</script>";
        die;
    }else{
        echo "<script>alert('修改失败！');window.location.href='./revise.php';</script>";
        die;
    }
